const joi = require('joi')

const username = joi.string().alphanum().min(1).max(10).required()
// 密码的验证规则,\S是非空字符，{6，12}位，/^$/开头和结尾
const password = joi.string().pattern(/^[\S]{6,12}$/).required()
const id = joi.number().integer().min(1).required()
const nickname = joi.string().required()
const email = joi.string().email().required()
const avatar = joi.string().dataUri().required()
// 注册和登录表单的验证规则对象
exports.reg_login_schema = {
		body: {
		username,
		password,
		},
}
exports.update_userinfo_schema = {
		body: {
		id,
		nickname,
		email,
		},
}exports.update_password_schema = {
body: {
oldPwd: password,
newPwd: joi.not(joi.ref('oldPwd')).concat(password),
},
}
exports.update_avatar_schema = {
body: {
avatar,
},
}